Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: apply FCU on invalid PayloadAttributes #4591

Merged
merged 2 commits into from
Sep 16, 2023

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Sep 13, 2023

Closes #4589

Makes the Invalid PayloadAttributes: Missing BeaconRoot hive test pass

This will call fork_choice_updated with None if the payload attributes fail validation.

@Rjected Rjected added C-bug An unexpected or incorrect behavior A-consensus Related to the consensus engine A-block-building Related to block building labels Sep 13, 2023
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #4591 (4acbc3c) into main (a572c3b) will decrease coverage by 0.06%.
Report is 1 commits behind head on main.
The diff coverage is 45.83%.

Impacted file tree graph

Files Changed Coverage Δ
crates/rpc/rpc-engine-api/src/engine_api.rs 78.96% <45.83%> (-0.27%) ⬇️

... and 10 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.72% <45.83%> (-0.02%) ⬇️
unit-tests 63.96% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 30.85% <ø> (ø)
blockchain tree 83.58% <ø> (ø)
pipeline 90.53% <ø> (ø)
storage (db) 75.32% <ø> (ø)
trie 94.84% <ø> (-0.04%) ⬇️
txpool 49.14% <ø> (-0.49%) ⬇️
networking 77.20% <ø> (-0.09%) ⬇️
rpc 57.37% <45.83%> (+<0.01%) ⬆️
consensus 63.40% <ø> (ø)
revm 31.56% <ø> (ø)
payload builder 6.12% <ø> (ø)
primitives 86.53% <ø> (-0.01%) ⬇️

Comment on lines 158 to 176
let attr_validation_res =
self.validate_version_specific_fields(EngineApiMessageVersion::V2, &attrs.into());

// From the engine API spec:
//
// Client software MUST ensure that payloadAttributes.timestamp is greater than
// timestamp of a block referenced by forkchoiceState.headBlockHash. If this condition
// isn't held client software MUST respond with -38003: Invalid payload attributes and
// MUST NOT begin a payload build process. In such an event, the forkchoiceState
// update MUST NOT be rolled back.
//
// NOTE: This will also apply to the validation result for the shanghai-specific fields
// provided in the payload attributes.
//
// To do this, we set the payload attrs to `None` if attribute validation failed, but
// we still apply the forkchoice update.
if let Err(err) = attr_validation_res {
let fcu_res = self.inner.beacon_consensus.fork_choice_updated(state, None).await?;
// TODO: decide if we want this branch - the FCU INVALID response might be more
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is duplicated code, right?

I think this could be moved to a helper function instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, added a helper

@Rjected Rjected force-pushed the dan/apply-fcu-on-invalid-payload-attrs branch from ca6d843 to 4acbc3c Compare September 15, 2023 19:07
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Rjected Rjected added this pull request to the merge queue Sep 16, 2023
Merged via the queue into main with commit f7b28e5 Sep 16, 2023
22 checks passed
@Rjected Rjected deleted the dan/apply-fcu-on-invalid-payload-attrs branch September 16, 2023 20:03
@mattsse mattsse added the M-changelog This change should be included in the changelog label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block-building Related to block building A-consensus Related to the consensus engine C-bug An unexpected or incorrect behavior M-changelog This change should be included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reth does not apply FCU on invalid payload attributes
2 participants